package cn.yuanqiao.web.controller.archive.jiashicang.controller;

import cn.yuanqiao.archive.jiashicang.service.CockPitService;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.core.controller.BaseController;

import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.enums.BusinessType;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/cockPit")
public class CockPitController extends BaseController {
    @Autowired
    private CockPitService cockPitService;

    @GetMapping("/onlineNums")
    @Log(title = "驾驶舱在线人数", businessType = BusinessType.SELECT)
    public AjaxResult onlineNums()
    {
        JSONObject  list = cockPitService.onlineNums();
        return AjaxResult.success(list);
    }

    @GetMapping("/stockNums")
    @Log(title = "驾驶舱库存统计", businessType = BusinessType.SELECT)
    public AjaxResult stockNums()
    {
        List<Map<String, Object>>  list = cockPitService.stockNums();
        return AjaxResult.success(list);
    }

    @GetMapping("/storeRoomNums")
    @Log(title = "驾驶舱库房统计", businessType = BusinessType.SELECT)
    public AjaxResult storeRoomNums()
    {
        List<Map<String, Object>> list = cockPitService.storeRoomNums();
        return AjaxResult.success(list);
    }

    @GetMapping("/utilizingStatisticsNums")
    @Log(title = "驾驶舱利用统计", businessType = BusinessType.SELECT)
    public AjaxResult utilizingStatisticsNums(@RequestParam("type") String type)
    {
        JSONObject list = cockPitService.utilizingStatisticsNums(type);
        return AjaxResult.success(list);
    }

    @GetMapping("/digitalStatisticsNums")
    @Log(title = "驾驶舱数字化统计", businessType = BusinessType.SELECT)
    public AjaxResult digitalStatisticsNums()
    {
        List<Map<String, Object>>  list = cockPitService.digitalStatisticsNums();
        return AjaxResult.success(list);
    }

    @GetMapping("/handOverReceiveNums")
    @Log(title = "移交统计", businessType = BusinessType.SELECT)
    public AjaxResult handOverReceiveNums()
    {
        JSONObject list = cockPitService.handOverReceiveNums();
        return AjaxResult.success(list);
    }

    @GetMapping("/receptionNums")
    @Log(title = "接收统计", businessType = BusinessType.SELECT)
    public AjaxResult receptionNums()
    {
        JSONObject list = cockPitService.receptionNums();
        return AjaxResult.success(list);
    }

    @GetMapping("/handOverReceiveNumsByYear")
    @Log(title = "移交统计按年度", businessType = BusinessType.SELECT)
    public AjaxResult handOverReceiveNumsByYear()
    {
        JSONArray list = cockPitService.handOverReceiveNumsByYear();
        return AjaxResult.success(list);
    }

    @GetMapping("/receptionNumsByYear")
    @Log(title = "接收统计按年度", businessType = BusinessType.SELECT)
    public AjaxResult receptionNumsByYear()
    {
        JSONArray list = cockPitService.receptionNumsByYear();
        return AjaxResult.success(list);
    }

    @GetMapping("/archiveFileNums")
    @Log(title = "驾驶舱电子档案归档饼状图统计", businessType = BusinessType.SELECT)
    public AjaxResult archiveFileNums()
    {
        List<Map<String, Object>>  list = cockPitService.archiveFileNums();
        return AjaxResult.success(list);
    }

    @GetMapping("/archiveFileNums2")
    @Log(title = "驾驶舱电子档案归档折线图统计", businessType = BusinessType.SELECT)
    public AjaxResult archiveFileNums2()
    {
        JSONObject  list = cockPitService.archiveFileNums2();
        return AjaxResult.success(list);
    }

    @GetMapping("/updateRedisData")
    @Log(title = "更新缓存", businessType = BusinessType.UPDATE)
    public AjaxResult updateRedisData()
    {
        int i = cockPitService.updateRedisData();
        return toAjax(i);
    }


}
